/**
 *
 */
package com.ebocy.hammer.world.handler;

import org.apache.log4j.Logger;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

import com.ebocy.hammer.core.constants.GameMessageCode;
import com.ebocy.hammer.core.handler.IMessageHandler;
import com.ebocy.hammer.core.log.EbocyLogManager;
import com.ebocy.hammer.core.message.IMessage;
import com.ebocy.hammer.world.service.WorldService;

/**
 * @author Qingrong Hou
 *
 * May 15, 2012
 */
public class SenderHandler extends IoHandlerAdapter implements IMessageHandler  {
	private static Logger logger = EbocyLogManager.getSystemLogger();
	private static short[] messageCodes = { };
	private WorldService worldService = WorldService.getInstance();
	private static SenderHandler handler = null;

	public SenderHandler() {
	}

	public static SenderHandler getInstance() {
		if (handler == null) {
			handler = new SenderHandler();
		}
		return handler;
	}

	@Override
	public short[] getMessageCodes() {
		return messageCodes;
	}

	@Override
	public void resolve(IMessage message, IoSession session) {
//		GamePlayer gamePlayer = GameCache.getInstance().getOnlineGamePlayers().get(session.getId());
		switch (message.getMessageCode()) {
		case GameMessageCode.LOGIN:
			//worldService.login(session,"123");
			break;

		default:
			logger.error("code" + message.getMessageCode() + "未处理！");
		}
	}
}
